package com.example.design.c.state.demo2;

/**
 * 分数状态
 * 不及格
 */
public class LowState extends AbstractScoreState {

    public LowState(ScoreContext context) {
        this.setContext(context);
        this.setStateName("不及格");
    }

    public LowState(AbstractScoreState state) {
        this.setContext(state.getContext());
        this.setStateName("不及格");
        this.setTotalScore(state.getTotalScore());
    }

    @Override
    protected void checkState() {
        int totalScore = getTotalScore();

        ScoreContext context = getContext();
        if (totalScore >= 90) {
            context.setScoreState(new HighState(this));
            return;
        }
        if (totalScore >= 60) {
            context.setScoreState(new MiddleState(this));
        }
    }
}
